package com.ruoyi.http.controller;

import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.http.domain.MyRequest;
import com.ruoyi.http.domain.WeChat02500T;
import com.ruoyi.http.service.IWeChatTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/http/weChat02500")
public class WeChat02500 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;

    @PostMapping("/weChat")
    public AjaxResult http(MyRequest request) {
/*        System.out.println("#####################################"+request.getListData());*/
        List<Map<String,String>> listData = (List<Map<String,String>>) JSONArray.parse(request.getListData());
/*        System.out.println("$$$$$$$$$$$"+listData.get(0).get("areaname"));*/
        for (Map<String,String> weChat:listData) {
            System.out.println(weChat.get("voteid"));
            WeChat02500T w=new WeChat02500T();
            w.setAnswer(weChat.get("answer"));
            w.setAreaname(weChat.get("areaname"));
            w.setOpenid(weChat.get("openid"));
            w.setVoteid(weChat.get("voteid"));
            w.setTopicid(weChat.get("topicid"));
            weChatTService.insertHouseVoteScoreDetail(w);
        }
        return AjaxResult.success(1);
    }
}